<?php


namespace App\Repositories;



use App\Models\Question;
use Illuminate\Support\Facades\Cache;
class QuestionRepository extends Repository
{
    protected $modelClass = Question::class;

    public function get($is_cache=true){

        if (Cache::has(config('global.cache.question')) && $is_cache){
            $question = Cache::get(config('global.cache.question'));
        }else{
            $question = $this->model()->where('status',1)->orderBy('sort')->get();
            Cache::set(config('global.cache.question'),$question);
        }

        return $question;
    }

    public function find($id){
        return $this->get()->firstWhere('id',$id);
    }



}
